package com.cn.wanxi.service;

import com.cn.wanxi.dao.NewsDao;
import com.cn.wanxi.model.NewsModel;

public class NewsService {
    /**
     * 封装新闻信息
     *
     * @return
     */
    public NewsModel[] getNewsModels() {
        NewsDao newsDao = new NewsDao();
        int length = newsDao.ids.length;
        NewsModel[] newsModels = new NewsModel[length];
        for (int i = 0; i < length; i++) {
            NewsModel model = new NewsModel();
            model.setId(newsDao.ids[i]);
            model.setContent(newsDao.contents[i]);
            model.setTitle(newsDao.titles[i]);
            newsModels[i] = model;
        }
        return newsModels;
    }

    /**
     * 封装信息页面新闻shuju
     *
     * @return
     */
    public NewsModel[] getNewsModelsForNewsPage() {
        NewsDao newsDao = new NewsDao();
        int length = newsDao.idsForNewsPage.length;
        NewsModel[] newsModels = new NewsModel[length];
        for (int i = 0; i < length; i++) {
            NewsModel model = new NewsModel();
            model.setId(newsDao.idsForNewsPage[i]);
            model.setPublishTime(newsDao.publishTimeForNewsPage[i]);
            model.setTitle(newsDao.titles[i]);
            newsModels[i] = model;
        }
        return newsModels;
    }
}
